package com.boot.security.server.dao;

import java.util.List;
import java.util.Map;

import com.boot.security.server.model.AppAccount;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.boot.security.server.model.AppFamMembe;

@Mapper
public interface AppFamMembeDao {

    @Select("select * from app_fam_membe t where t.id = #{id}")
    AppFamMembe getById(Long id);

    @Delete("delete from app_fam_membe where id = #{id}")
    int delete(Long id);

    int update(AppFamMembe appFamMembe);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into app_fam_membe(fids, fammembeid, openId, fno, realName, sex, phoneNo, status, patientNo, socialSecurityCard, medicareCard, medicalCard, idCard, militaryId, agreementId, patientid, times, userid, accountid, famtime, csrq, hostcode, responsetype,cardtype,cardno) values(#{fids}, #{fammembeid}, #{openId}, #{fno}, #{realName}, #{sex}, #{phoneNo}, #{status}, #{patientNo}, #{socialSecurityCard}, #{medicareCard}, #{medicalCard}, #{idCard}, #{militaryId}, #{agreementId}, #{patientid}, #{times}, #{userid}, #{accountid}, #{famtime}, #{csrq}, #{hostcode}, #{responsetype}, #{cardtype} ,#{cardno})")
    int save(AppFamMembe appFamMembe);
    
    int count(@Param("params") Map<String, Object> params);

    List<AppFamMembe> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);
    @Select("select * from app_fam_membe t where t.openId = #{openId} or  t.cardno = #{cardno} or  t.idCard = #{idCard} or  t.cardtype = #{cardtype}  or  t.phoneNo = #{phoneNo}  ")
    List<AppFamMembe> getfamlist(@Param("openId") String openId, @Param("cardno") String cardno, @Param("idCard") String idCard, @Param("cardtype") String cardtype, @Param("phoneNo") String phoneNo);
}
